package ua.pp.bizon.cripto.authorization;

import java.io.IOException;

import ua.pp.bizon.cripto.keystore.CryptoException;

public class Credentials {

    private String username;

    private byte[] hashedPassword;

    public static Credentials c;

    public Credentials() {
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setHashedPassword(byte[] hashedPassword) {
        this.hashedPassword = hashedPassword;
    }

    @Deprecated
    public synchronized static String login() {
        return c == null ? null : c.username;
    }

    @Deprecated
    public synchronized static Credentials init(UI ui) throws IOException, CryptoException {
        c = new Credentials();
        ui.login(c);
        return c;
    }

    @Deprecated
    public synchronized static byte[] password() {
        return c == null ? null : c.hashedPassword;
    }

    public String getUsername() {
        return username;
    }

    public byte[] getHashedPassword() {
        return hashedPassword;
    }

}
